package net.zhuike.novel.app.service;

import android.content.Context;

import net.zhuike.novel.app.bean.AutoComplete;
import net.zhuike.novel.app.bean.BookMixAToc;
import net.zhuike.novel.app.bean.ChapterRead;
import net.zhuike.novel.app.bean.HotWord;
import net.zhuike.novel.app.bean.SearchDetail;

import framework.common.zanetwork.UeHttpUrl;
import framework.common.zanetwork.core.HttpCallback;
import framework.common.zanetwork.core.ResponseCallback;
import okhttp3.Response;

/**
 * Created by qi.wang on 2017/6/12.
 * 搜索service
 */

public class SearchService extends BaseService{
    public static  void getHotWordList(final Context context, final ResponseCallback<HotWord> callback){
        httpHelper.get(UeHttpUrl.getHotWordList(), null, new HttpCallback<HotWord>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, HotWord o) {
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static  void getSearchResultList(final Context context,final String key, final ResponseCallback<SearchDetail> callback){
        httpHelper.get(UeHttpUrl.getSearchResultList()+key+"/", null, new HttpCallback<SearchDetail>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, SearchDetail o) {
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
    public static  void getChapterRead(final Context context,String url,int viewChapters, final ResponseCallback<ChapterRead> callback){
        httpHelper.get(UeHttpUrl.getChapterRead()+url, null, new HttpCallback<ChapterRead>() {
            @Override
            public void onRequestBefore() {

            }

            @Override
            public void onSuccess(Response response, ChapterRead o) {
                callback.onSuccess(o);
            }

            @Override
            public void onError(Response response, int errorCode, Exception e) {
                callback.onError(response, errorCode, null, e);

            }

            @Override
            public void onFailure(Response response, String failureMsg, int code) {
                callback.onError(response, code, failureMsg, null);
            }
        });
    }
}
